import { EggAppConfig, PowerPartial } from 'egg';
import path = require('path');

export default () => {
  const config: PowerPartial<EggAppConfig> = {};
  // 添加sequelize配置
  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    port: 3306,
    username: 'root',
    password: '123456',
    database: 'heimaserver',
    timezone: '+8:00',
    dialectOptions: {
      useUTC: false,
    },
  };
  // 禁用CSRF安全校验
  config.security = {
    csrf: {
      enable: false,
    },
  };
  // 开启 redis 端口和数据库必须是数字格式
  config.redis = {
    client: {
      host: '127.0.0.1',
      port: 6379,
      password: '',
      db: 0,
    },
  };
  // 设置 samesite
  config.cluster = {
    https: {
      key: path.join(__dirname, '../private.pem'), // https 证书绝对目录
      cert: path.join(__dirname, '../file.crt'), // https 证书绝对目录
    },
  };
  config.cluster = {
    sameSite: 'none',
  };
  return config;
};
